package com.princess.demok.ui.demo

import android.app.Activity
import android.content.Intent
import android.view.Menu
import android.view.MenuItem
import android.view.View
import androidx.appcompat.app.ActionBarDrawerToggle
import androidx.drawerlayout.widget.DrawerLayout
import com.princess.baselib.utils.LogUtils
import com.princess.demok.R
import com.princess.demok.base.view.MyBaseActivity
import kotlinx.android.synthetic.main.activity_drawer.*

/**
 * @author: xha
 * @date: 2021/10/20 14:56
 * @Description:
 */
@Suppress("UNREACHABLE_CODE")
class DrawerActivity : MyBaseActivity(){

    companion object {
        @JvmStatic
        fun start(
            context: Activity
        ) {
            val starter = Intent(context, DrawerActivity::class.java)
            context.startActivity(starter)
        }
    }

    override fun getLayoutId(): Int {
        return R.layout.activity_drawer
    }

    override fun initOnCreate() {

        setHeaderColor(R.color.color_blue)
        showTitle(false)

        setSupportActionBar(toolBarDrawer)

        toolBarDrawer.inflateMenu(R.menu.tool)


        supportActionBar?.setDisplayHomeAsUpEnabled(true)



        val drawerToggle = ActionBarDrawerToggle(this,drawerlayoutDrawer,toolBarDrawer,R.string.app_name,R.string.app_name)
        drawerlayoutDrawer.addDrawerListener(drawerToggle);
        drawerToggle.syncState()

    }

    override fun initOnClickerListener() {
        super.initOnClickerListener()

    }

    override fun onCreateOptionsMenu(menu: Menu?): Boolean {
//        return super.onCreateOptionsMenu(menu)
        menuInflater.inflate(R.menu.tool, menu);
        return true;
    }

    override fun onOptionsItemSelected(item: MenuItem): Boolean {
        return super.onOptionsItemSelected(item)
        when (item.itemId) {
            R.id.action_favorite -> {
                LogUtils.i("点击 action_favorite")
            }
            R.id.action_settings -> {
                LogUtils.i("点击 action_settings")
            }
        }
    }


}